{include file='public/header.html'}

<div class="container blog mtn">


    <div class="panel panel-default">
        <div class="panel-heading">
            <i class="glyphicon glyphicon-book"></i> 最新文集
            {if session('user.level')>=2:}
            <span class="pull-right"><a href="{:url('book/add')}"><i class="glyphicon glyphicon-plus"></i> 添加文集</a></span>
            {/if}
        </div>
        <div class="panel-body row">

            {php $list=db('book')->where('status=1')->order('is_top DESC,sort ASC,id DESC')->limit(8)->cache()->select()}
            {foreach $list as $vo}
            {php $start_id=get_start_id($vo['id'])}
            <div class="col-lg-3">
                <div class="panel panel-default">
                    <a href="{:url('doc/read',['id'=>$start_id])}">
                        <img class="card-img-top" src="{:rand_thumb($vo['thumb'], $vo['id'])}" width="100%" alt="{$vo.title}" />
                    </a>
                    <div class="panel-body">
                        <h4 class="card-title">{if $vo['is_top']==1:}<span class="text-danger">置顶</span> {/if}<a href="{:url('book/detail',['id'=>$vo['id']])}">{$vo.title}</a>
                        </h4>
                        <div class="card-text summary">{$vo.summary|str_substr=90}</div>
                    </div>
                    <div class="panel-footer text-right">
                        {if $vo['is_public']==0:}
                        <a href="{:url('book/vip')}" class="text-danger"><i class="glyphicon glyphicon-lock"></i> VIP</a>&nbsp;
                        {else:}
                        <a href="{:url('book/index')}"><i class="glyphicon glyphicon-bookmark"></i> 公共</a>&nbsp;
                        {/if}
                        <a href="{:url('user/info',['id'=>$vo['user_id']])}"><i class="glyphicon glyphicon-user"></i> {$vo.user_id|get_nickname}</a>&nbsp;
                        <a href="{:url('book/down', ['id'=>$vo['id']])}"><i class="glyphicon glyphicon-download"></i> 下载</a>
                    </div>
                </div>
            </div>
            {/foreach}
        </div>
    </div>

    <!--公告-->
    <div class="well clearfix">
        <strong>公告：<span class="text-danger">{site('site_notice') ?: '暂无公告！'}</span></strong>
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">
            <i class="glyphicon glyphicon-flag"></i> 最新文档
            <span class="pull-right"><a href="{:url('doc/index')}">更多&raquo;</a></span>
        </div>
        <div class="panel-body">
            {php $book = db('book')->where('status=1')->column('title', 'id')}
            {php $book_ids = array_keys($book)}
            {php $last=db('doc')->field('id,title,book_id,summary,update_time,user_id')->where('book_id','in',$book_ids)->where('status=1')->limit(5)->order('update_time DESC,id DESC')->select()}
            {foreach $last as $dvo}
            <div class="blog-list">
                <h4><a href="{:url('doc/read',['id'=>$dvo['id']])}"><i class="glyphicon glyphicon-file"></i> {$dvo.title} - {$book[$dvo['book_id']]}</a></h4>
                <p>{$dvo.summary|str_substr=70}</p>
                <p>
                    <i class="glyphicon glyphicon-time"></i> {$dvo.update_time|get_time_ago}&nbsp;&nbsp;
                    <a href="{:url('user/info',['id'=>$dvo['user_id']])}"><i class="glyphicon glyphicon-user"></i> {$dvo.user_id|get_nickname}</a>&nbsp;&nbsp;
                    <a href="{:url('doc/down',['id'=>$dvo['id']])}"><i class="glyphicon glyphicon-download-alt"></i> 下载</a>
                </p>
            </div>
            {/foreach}
        </div>
    </div>

</div>

{include file='public/footer.html'}

</body>
</html>